package com.huayal.mall.search.controller;

import com.huayal.common.utils.R;
import com.huayal.common.vo.es.SkuESModel;
import com.huayal.mall.search.service.SkuAddService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/es")
public class SkuAddController {

    @Autowired
    SkuAddService skuAddService;

    /**
     * 批量上架Sku信息 把数据存入ES
     * @param skuESModels
     * @return
     */
    @PostMapping("/saveSkuESModels")
    public Boolean saveSkuESModels(@RequestBody List<SkuESModel> skuESModels) {

        try {
            return skuAddService.saveSkuESModels(skuESModels);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return false;
    }
}
